package com.feiyang.ni.test;

import javax.swing.*;
import java.awt.event.ActionListener;
import java.awt.event.ActionEvent;
import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;

public class MyFrame2 extends JFrame implements MouseListener {
    JButton jbt = new JButton("点我啊~");
    public MyFrame2(){
        this.setSize(400,300);
        this.setTitle("检测检查");
        this.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
        this.setLocationRelativeTo(null);
        this.setLayout(null);
        jbt.setBounds(0,0,200,100);
        jbt.addMouseListener(this);
        this.getContentPane().add(jbt);
        this.setVisible(true);
    }

    @Override
    public void mouseClicked(MouseEvent e) {
        jbt.setText("点我干嘛？");
    }

    @Override
    public void mousePressed(MouseEvent e) {
        jbt.setText("按紧不松");
    }

    @Override
    public void mouseReleased(MouseEvent e) {
        jbt.setText("松了吧？");
    }

    @Override
    public void mouseEntered(MouseEvent e) {
        jbt.setText("鼠标进入了");
    }

    @Override
    public void mouseExited(MouseEvent e) {
        jbt.setText("鼠标离开了");
    }

}
